/*
Class Name      : TestMessagesController
Created by      : Sreekanth SV Vegi
Created On      : 23/02/2013
Description     : This class helps to test MessagesController Class
Version         : 1.0               
*/

@isTest
public with sharing class TestMessagesController {

    //Test method for posting message and testing errormessage
    
    static testMethod void TestdoPostMessagesinsertController () {
        
        //Create consolehomecontroller object to pass as parameter to MessageController constructor
        ConsoleHomeController_AC  consolehome=new ConsoleHomeController_AC ();
        
        //Call the constructors
        MessagesController messController=new MessagesController();
        MessagesController messController1=new MessagesController(consolehome);
        
        //Get the message and post
        Message__c testmessage=messController.getMessage();
        testmessage.Description__c='Hai good morning';
        PageReference rf=messController.doPostMessage();
       
       //Checking of errMessage obje
        messController.errMessage('Please Enter Message');
        
      }
      
    //Test method for dopost method with empty message  
      static testMethod void TestdoPostMessagesErrorController () {
       
        //Call the constructors
        MessagesController messController=new MessagesController();
        
        //Get the empty message and post
        Message__c testmessage=messController.getMessage();
        testmessage.Description__c='';
        PageReference rf=messController.doPostMessage();
               
      }
    
    //Test method for display top5messages and all messages
    static testMethod void TestMoreMessagesController () {
    
        //Create 6 messages and insert
        Message__c testmessage1=new Message__c(Name='Test1',Description__c='Hello All, Today is our friend Anirudh birthday,wish him');
        Message__c testmessage2=new Message__c(Name='Test2',Description__c='Hello All, Tomorrow is holiday for all teams');
        Message__c testmessage3=new Message__c(Name='Test3',Description__c='Hello All, Good Morning');
        Message__c testmessage4=new Message__c(Name='Test3',Description__c='Hello All, Good Evening');
        Message__c testmessage5=new Message__c(Name='Test3',Description__c='Hello All, Good Afternoon');
        Message__c testmessage6=new Message__c(Name='Test3',Description__c='Hello All, Good Night');
        
        insert testmessage1;
        insert testmessage2;
        insert testmessage3;
        insert testmessage4;
        insert testmessage5;
        insert testmessage6;
       
        //Call the constructors
        MessagesController messController=new MessagesController();
        
        //Call the display message methods 
        PageReference rf1=messController.Top5messages();
        PageReference rf2=messController.Allmessages();
       
    }
}